#include <stdio.h>
#include <stdlib.h>

#define SQUARE(value) ((value) * (value))

int main(void) {
    int t;
    scanf("%d", &t);
    // BREAKPOINT BELOW
    for(int i = 0; i < t; i++) {
        int n;
        scanf("%d", &n);
        int* a = (int*) calloc(n, sizeof(int));
        for (int k = 0; k < n; k++) {
            scanf("%d", &a[k]);
        }
        for (int x = 0; x < n - 1; x++) {
            for (int y = 0; y < n - 1; y++) {
                if (a[y] > a[y + 1]) {
                    int tmp = a[y];
                    a[y] = a[y + 1];
                    a[y + 1] = tmp;
                }
            }
        }
        int result = 0;
        for (int x = 2; x < n; x++) {
            for (int ia = x - 1; ia >= 0; ia--) {
                for (int ib = ia - 1; ib >= 0; ib--) {
                    if (a[x] < a[ia] + a[ib]) {
                        if (SQUARE(a[x]) < SQUARE(a[ia]) + SQUARE(a[ib])) {
                            result++;
                        }
                    }
                }
            }
        }
        printf("%d\n", result);
    }
    return 0;
}
